#ifndef GLPANEL_H
#define GLPANEL_H

#include <qgl.h>
#include <vector>
#include <map>
using namespace std;
class QMouseEvent;
#include "mesh.h"


class GLPanel : public QGLWidget
{
    Q_OBJECT

public:

    GLPanel( QWidget* parent, const char* name );
    ~GLPanel();
	GLPanel();
    void viewMesh( Mesh* _pMesh );
	void    setmode( bool _mode);
	bool    getmode();

public slots:

    void    mousePressEvent( QMouseEvent* event );
    void    mouseMoveEvent( QMouseEvent* event );

protected:

    void		initializeGL();
    void		paintGL();
    void		resizeGL( int w, int h );
    virtual GLuint 	makeObject();
    void tri( GLenum primitive, GLdouble x1, GLdouble y1, GLdouble z1,
              GLdouble x2, GLdouble y2, GLdouble z2,
              GLdouble x3, GLdouble y3, GLdouble z3);
    void quad( GLenum primitive, GLdouble x1, GLdouble y1, GLdouble z1,
               GLdouble x2, GLdouble y2, GLdouble z2,
               GLdouble x3, GLdouble y3, GLdouble z3,
               GLdouble x4, GLdouble y4, GLdouble z4);


private:

    GLfloat angle, fAspect; 
    GLuint object;
    Mesh* m_pMesh;
    double m_minX;
    double m_maxX;
    double m_minY;
    double m_maxY;
    double m_minZ;
    double m_maxZ;
    int m_lastW;
    int m_lastH;
    // The QPoint is a Qt class that defines a point in a plane
    // i.e. the position of the mouse on the screen.
    int raster_x;
    int raster_y;
    int old_raster_x;
    int old_raster_y;
    // To indicate whether the mouse is moving while a mouse button is pressed
    int moving;
	bool mode;
};


#endif // GLPANEL_H
